package LuoGu.贪心.合并果子;

import java.util.Scanner;

public class Main_1 {
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        int n = s.nextInt();
        long anss = 0;
        long [] ans = new long [n];
        for(int i=0;i<n;i++){
            ans[i] = s.nextLong();
        }
        for(int i=1;i<n;i++){
            ans[i] += ans[i-1];
            anss+=ans[i];
        }
        System.out.print(anss);
    }
}
